<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>餐厅优惠管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<%@ include file="../include/jsCss.jsp" %>
  </head>
  
  <body>
  	<form action="preferential/preferential!adminMealMenu.html" method="post" id="frmAdminSelectPreferential">
		优惠管理
		<hr/>
		<table width="130%">
			<tr>
				<td>优惠名称   <input type="text" name="name"/>
					<input type="button" value="搜索" onclick="javascript:btnSelectPreferential();"/></td>  
				
				<td style="text-align:left;">
					<a href="javascript:;" onclick="releasePreferential(1)">审核通过</a>
					<a href="javascript:;" onclick="releasePreferential(2);">审核不通过</a>
					<!--  <a href="javascript:;" onclick="releasePreferential(false);">作废</a>
					<a href="javascript:;" onclick="releasePreferential(false);">取消作废</a>
					<a href="javascript:;" onclick="releasePreferential(false);">删除</a>-->
				</td>
			</tr>
		</table>
     	<table width="130%" border="1">
			<tr>
				<td rowspan="1" ><input type="checkbox" name="CheckBoxAll" onclick="checkedAll(this)"/></td>
				<td>优惠名称</td>  
				<td>原价</td>
				<td>优惠价</td>
				<td>折扣幅度</td>
				<td>开始日期</td>
				<td>结束日期</td> 
				<td>优惠份数</td>
				<td>优惠介绍</td> 
				<td>发布状态</td>
				<td>状态</td>
			</tr>
			<s:iterator value="preferentialDtoListAdmin">
				<tr>
					<td>
						<input type="checkbox" name="statusCheckBox" value="${id}"/>
					</td>
					<td>
						${name}
					</td> 
				 
					<td>
						${costPrice}
					</td>
					<td>
						${preferentialPrice}
					</td>
					<td>
						${discount}
					</td>
					<td>
						${beginDate}
					</td>
					<td>
						${endDate}
					</td> 
					<td>${copies} </td>
					<td>${explanation }</td> 
					<td>
						<s:if test="releaseStatus == true">
							已发布
						</s:if>
						<s:else>
							未发布
						</s:else> 
					</td>
					<td>
						<s:if test="status == 0">
							审核中
						</s:if>
						<s:if test="status == 1">
							审核通过
						</s:if>
						<s:if test="status == 2">
							审核不通过
						</s:if>
						<s:if test="status == 3">
							作废
						</s:if>
					</td>
					
				</tr>
			</s:iterator>
		</table>
		<div>
			<jsp:include page="../include/page.jsp"></jsp:include> 
		</div>
	</form>
  </body>
</html>
<script type="text/javascript">
	function releasePreferential(status){
		
		var preferentialIds = "";
		$("input[name='statusCheckBox']").each(function(i,item){
			 if (item.checked == true) {
				 preferentialIds += item.value + ",";
			 }
		});
		 
		if (preferentialIds == "") {
			alert("请选择要发布的优惠!");
			return;
		}
		
		preferentialIds = preferentialIds.substring(0, preferentialIds.length-1);
		
			var dt = new Date();
			$.ajax( {
				type : "POST",
				url : "preferential/preferential!auditing.html",
				data : "preferentialIds="+preferentialIds+"&status="+status+"&date=" + dt,
				success : function(data) {
					if ($.trim(data) == 0) {
						if (status == 1) { 
							alert('审核成功!');
						}
						if (status == 2) {
							alert('审核不通过成功');
						}
						document.location.reload();
					} else {
						alert('操作失败!');
					}
				}
			}); 
		
	}
</script>